// JavaScript Document
var domain = "http://10.9.156.90:8080/";
window.onload = function(){
	
	//获取购物车a标签外层的div对象
	var shopCarObj = $id("site-topbar").children[0].children[1].children[1];
	//获取购物车中小图标
	var imgObj = shopCarObj.children[0].children[0];
	//获取购物车详细信息小框对象
	var shopCarListObj = $id("shopCar-list");
	//鼠标滑过shopCarObj时的事件
	shopCarObj.onmouseover = function(){
		shopCarObj.style.background = "#FFF";
		shopCarObj.children[0].style.color = "#ff6700";
		imgObj.src = "../images/shopcar1.png";
		shopCarListObj.style.display = "block";
		
		startMove(shopCarListObj,{"height":100});
		
		var xhr = getAjax(domain + "MaxAjax/XiaoMi/json/shopCar.json",callback);
		
		function callback(data){
			shopCarListObj.innerHTML = data[0].value;
			shopCarListObj.style.textAlign = "center";
			shopCarListObj.style.zIndex = "100";
		}
		
	}
	//鼠标离开shopCarObj时的事件
	shopCarObj.onmouseout = function(){
		shopCarObj.style.background = "#424242";
		shopCarObj.children[0].style.color = "#b0b0b0";
		imgObj.src = "../images/shopcar.png";
		startMove(shopCarListObj,{"height":0});
		shopCarListObj.innerHTML = "";
		
	}
	
	
	
	//search部分的menu中的ul对象中li集合
	var menuLiList = $id("search").children[1].children[0].children;
	// for(var i = 0; i < menuLiList.length - 2; i++){
	// 	menuLiList[i].onmouseover = function(){
			 
	// 	}
	// 	menuLiList[i].onmouseout = function(){
			
	// 	}
	// }
	
	//获取搜索框的form对象
	var formObj = $id("search").children[2].children[0];
	//search部分的search表单中的搜索框对象txtObj
	var txtObj = formObj.children[0];
	//获取搜索按钮对象
	var btnObj = formObj.children[1];
	//鼠标滑过文本搜索框时的事件
	txtObj.onmouseover = function(){
		this.style.border = "1px solid #999";
		btnObj.style.border = "1px solid #999";
	}
	//鼠标离开文本搜索框时的事件
	txtObj.onmouseout = function(){
		this.style.border = "1px solid #CCC";
		btnObj.style.border = "1px solid #CCC";
	}
	var searchInfoObj = $id("search-info");
	console.log(txtObj.style.border)
	//给搜索框添加鼠标点击事件
	txtObj.onclick = function(){
		this.style.border = "1px solid #ff6700";
		btnObj.style.border = "1px solid #ff6700";
		searchInfoObj.style.display = "block";
	}	
	// //
	// txtObj.onblur = function(){
	// 	txtObj.style.border = "";
	// 	// btnObj.style.border = "";
	// 	searchInfoObj.style.display = "none";
	// }
	//鼠标滑过搜索按钮时改变样式的事件
	btnObj.onmouseover = function(){
		this.style.background = "#ff6700 url(../images/search2.png)";
		this.parentNode.children[1].style.backgroud = "#ff6700";
	}
	//鼠标离开搜索按钮时改变样式的事件
	btnObj.onmouseout = function(){
		this.style.background = "";
	}
	
	
	//获取home-hero-slider-kind部分的ul对象
	var homeHeroUlList = $id("home-hero-container").children[0].children[0].children[0].children[0];
	
	
	//获取home-hero-slider部分的banner
	var bannerObj = $id("home-hero-container").children[0].children[0].children[1];
	
	
	//获取J-homeStar-switch对象
	var JHomeStarSwitchObj = $id("home-hero-container").children[1].children[1];
	//J-homeStar中向左滑动按钮箭头
	var turnLeft = JHomeStarSwitchObj.children[0];
	//J-homeStar中向右滑动按钮箭头
	var turnRight = JHomeStarSwitchObj.children[1];
	
	
	//获取J-homeStar-content中的dl集合 #ff6700 #83c44e #e53935 #2196f3
	var JHomeStarContentObj = $id("home-hero-container").children[1].children[2].children;
	
	
	
	
	//获取container对象
	var containerObj = $id("container");
	/* ***********************container中smart部分************** */
	//获取smart对象(智能硬件)
	var smartObj = containerObj.children[0];
	//获取查看全部a标签
	var smartAllcheckedObj = smartObj.children[1].children[0];
	//滑过a标签时，改变样式和图片事件
	smartAllcheckedObj.onmouseover = function(){
		this.className = "on";
		this.children[0].src = "../images/allchecked1.png";
	}
	//离开a标签时，改变样式和图片的事件
	smartAllcheckedObj.onmouseout = function(){
		this.className = "";
		this.children[0].src = "../images/allchecked01.png";
	}
	//获取smart-content-slider对象
	var smartContentSlideBarObj = smartObj.children[2].children[0];
	//给smart-content-slider对象添加鼠标滑过事件
	smartContentSlideBarObj.onmouseover = function(){
		this.style.boxShadow = "7px 7px 7px #e0e0e0";
	}
	//给smart-content-slider对象添加鼠标离开事件
	smartContentSlideBarObj.onmouseout = function(){
		this.style.boxShadow = "";
	}
	//获取smart中dl集合
	var smartDlList = smartObj.children[2].children[1].children;
	//遍历smart中dl集合，给每个dl添加事件
	for(var i = 0; i < smartDlList.length; i++){
		//分别给每个smart中的dl添加鼠标滑过事件
		smartDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
			startMove(this,{top:20});
		}
		//分别给每个smart中的dl添加鼠标离开事件
		smartDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
			startMove(this,{top:0});
		}
	}

	/* ***********************container中macth部分************** */
	//获取match对象(搭配)
	var matchObj = containerObj.children[1];
	//match中switch中的a标签集合
	var matchAList = matchObj.children[1].children;
	//获取match-content-slider对象集合
	var matchContentSlideBarObj = matchObj.children[2].children[0].children;
	//获取match中dl集合
	var matchDlList = matchObj.children[2].children[1].children;
	//循环遍历每个a，给他们分别加事件
	for(var i = 0; i < matchAList.length; i++){
		//给match中的switch中的每个a添加鼠标滑过事件
		matchAList[i].index = i;
		//给match中的switch中的每个a添加鼠标离开事件
		matchAList[i].onmouseover = function(){
			this.style.color = "#ff6700";
			this.style.borderBottom = "2px solid #ff6700";
			for(var j = 0; j < matchDlList.length; j++){
				matchDlList[j].children[0].children[0].children[0].src = 
					"../images/match0" + (this.index + 1) + ".jpg";
			}
		}
		//给match中的switch中的每个a添加鼠标离开事件
		matchAList[i].onmouseout = function(){
			this.style.color = "";
			this.style.borderBottom = "";
			//定义一个变量存放上一次onmouseover时的样式
		}
	}
	//
	for(var i = 0; i < matchContentSlideBarObj.length; i++){
		//给match-content-slider对象添加鼠标滑过事件
		matchContentSlideBarObj[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//给match-content-slider对象添加鼠标离开事件
		matchContentSlideBarObj[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	//遍历match中dl集合，给每个dl添加事件
	for(var i = 0; i < matchDlList.length; i++){
		//分别给每个match中的dl添加鼠标滑过事件
		matchDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//分别给每个match中的dl添加鼠标离开事件
		matchDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	
	
	/* ***********************container中accessories部分************** */
	//获取accessories对象(配件)
	var accessoriesObj = containerObj.children[2];
	//accessories中switch中的a标签集合
	var accessoriesAList = accessoriesObj.children[1].children;
	//获取accessories-content-slider对象集合
	var accessoriesContentSlideBarObj = accessoriesObj.children[2].children[0].children;
	//获取accessories中dl集合
	var accessoriesDlList = accessoriesObj.children[2].children[1].children;
	//循环遍历每个a，给他们分别加事件
	for(var i = 0; i < accessoriesAList.length; i++){
		accessoriesAList[i].index = i;
		//
		accessoriesAList[i].onmouseover = function(){
			this.style.color = "#ff6700";
			this.style.borderBottom = "2px solid #ff6700";
			for(var j = 0; j < accessoriesDlList.length; j++){
				accessoriesDlList[j].children[0].children[0].children[0].src = 
					"../images/accessories" + (this.index + 4) + ".jpg";
			}
		}
		//
		accessoriesAList[i].onmouseout = function(){
			this.style.color = "";
			this.style.borderBottom = "";
		}
	}

	//
	for(var i = 0; i < accessoriesContentSlideBarObj.length; i++){
		//给accessories-content-slider对象添加鼠标滑过事件
		accessoriesContentSlideBarObj[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//给accessories-content-slider对象添加鼠标离开事件
		accessoriesContentSlideBarObj[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	//遍历accessories中dl集合，给每个dl添加事件
	for(var i = 0; i < accessoriesDlList.length; i++){
		//分别给每个accessories中的dl添加鼠标滑过事件
		accessoriesDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//分别给每个accessories中的dl添加鼠标离开事件
		accessoriesDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	
	/* ***********************container中around部分************** */
	//获取around对象(周边)
	var aroundObj = containerObj.children[3];
	//around中switch中的a标签集合
	var aroundAList = aroundObj.children[1].children;
	//获取around-content-slider对象集合
	var aroundContentSlideBarObj = aroundObj.children[2].children[0].children;
	//获取around中li集合
	var aroundDlList = aroundObj.children[2].children[1].children;
	//循环遍历每个a，给他们分别添加事件
	for(var i = 0; i < aroundAList.length; i++){
		aroundAList[i].index = i;
		//
		aroundAList[i].onmouseover = function(){
			this.style.color = "#ff6700";
			this.style.borderBottom = "2px solid #ff6700";
			for(var j = 0; j < aroundDlList.length; j++){
				aroundDlList[j].children[0].children[0].children[0].src = 
					"../images/around" + (this.index + 2) + ".jpg";
			}
		}
		//
		aroundAList[i].onmouseout = function(){
			this.style.color = "";
			this.style.borderBottom = "";
		}
	}
	//
	for(var i = 0; i < aroundContentSlideBarObj.length; i++){
		//给around-content-slider对象添加鼠标滑过事件
		aroundContentSlideBarObj[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//给around-content-slider对象添加鼠标离开事件
		aroundContentSlideBarObj[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	//遍历around中dl集合，给每个dl添加事件
	for(var i = 0; i < aroundDlList.length; i++){
		aroundDlList[i].index = i;
		//分别给每个around中的dl添加鼠标滑过事件
		aroundDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//分别给每个around中的dl添加鼠标离开事件
		aroundDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	
	/* ***********************container中recommend部分************** */
	//获取recomment对象(为你推荐)
	var recommendObj = containerObj.children[4];
	//获取recomment中dl集合
	var recommentDlList = recommendObj.children[2].children;
	//
	var reconmmentContent = recommendObj.children[2];
	//获取向左箭头
	var toLeft = recommendObj.children[1].children[0];
	//获取向右箭头
	var toRight = recommendObj.children[1].children[1];
	//
	var reconmmentIndex = 0;
	//向左点击事件
	toLeft.onclick = function(){
		startMove(reconmmentContent,{left:1226});
	}

	//向右点击事件
	toRight.onclick = function(){
		// reconmmentIndex++;
		startMove(reconmmentContent,{left:-1226});
	}
	//遍历recomment中dl集合，给每个dl添加事件
	for(var i = 0; i < recommentDlList.length; i++){
		//分别给每个recomment中的dl添加鼠标滑过事件
		recommentDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//分别给每个recomment中的dl添加鼠标离开事件
		recommentDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	
	
	/* ***********************container中comment部分************** */
	//获取comment对象(热评产品)
	var commentObj = containerObj.children[5];
	//获取comment中dl集合
	var commentDlList = commentObj.children[1].children;
	//遍历comment中dl集合，给每个dl添加事件
	for(var i = 0; i < commentDlList.length; i++){
		//分别给每个comment中的dl添加鼠标滑过事件
		commentDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
		}
		//分别给每个comment中的dl添加鼠标离开事件
		commentDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
		}
	}
	
	
	/* ***********************container中content部分************** */
	//获取content对象(内容)
	var contentObj = containerObj.children[6];
	
	

	/* ***********************container中video部分************** */
	//获取video对象(视频)
	var videoObj = containerObj.children[7];
	//获取查看全部a标签
	var videoAllcheckedObj = videoObj.children[1].children[0];
	//滑过a标签时，改变样式和图片
	videoAllcheckedObj.onmouseover = function(){
		this.className = "on";
		this.children[0].src = "../images/allchecked1.png";
	}
	//离开a标签时，改变样式和图片
	videoAllcheckedObj.onmouseout = function(){
		this.className = "";
		this.children[0].src = "../images/allchecked01.png";
	}
	//获取video中dl集合
	var videoObjDlList = videoObj.children[2].children;
	
	//遍历video中dl集合，给每个dl添加事件
	for(var i = 0; i < videoObjDlList.length; i++){
		//分别给每个video中的dl添加鼠标滑过事件
		videoObjDlList[i].onmouseover = function(){
			this.style.boxShadow = "7px 7px 7px #e0e0e0";
			startMove(this,{top:20});
			
		}
		//分别给每个video中的dl添加鼠标离开事件
		videoObjDlList[i].onmouseout = function(){
			this.style.boxShadow = "";
			startMove(this,{top:0});
		}
	}

	
	for(var i = 0; i < videoObjDlList.length; i++){
		videoObjDlList[i].index = i;
		//给每个dt添加鼠标滑过事件
		videoObjDlList[i].children[0].onmouseover = function(){
			videoObjDlList[this.parentNode.index].children[0].children[1].children[0].src = 
			"../images/videorun1.png";
			videoObjDlList[this.parentNode.index].children[0].children[1].style.cssText = 
				"background:#f60; border-color:#f60; opacity:100; filter:alpha(opacity=100)";
		}
		//给每个dt添加鼠标离开事件
		videoObjDlList[i].children[0].onmouseout = function(){
			videoObjDlList[this.parentNode.index].children[0].children[1].children[0].src = 
				"../images/videorun01.png";
			videoObjDlList[this.parentNode.index].children[0].children[1].style.cssText = "";
		}
		
	}
	

	/* ***********************site-footer部分************** */
	//site-footer对象
	var siteFooterObj = $id("site-footer");
	//footer-service中的li集合
	var footerServiceLiList = siteFooterObj.children[0].children[0].children;
	//循环遍历每个li
	for(var i = 0; i < footerServiceLiList.length; i++){
		footerServiceLiList[i].index = i;
		//footer-service中li下的a添加鼠标滑过事件
		footerServiceLiList[i].onmouseover = function(){
			footerServiceLiList[this.index].children[0].style.color = "#ff6700";
			footerServiceLiList[this.index].children[0].children[0].src = 
				"../images/service" + ( this.index + 1 ) + ".png";
		}
		//footer-service中li下的a添加鼠标离开事件
		footerServiceLiList[i].onmouseout = function(){
			footerServiceLiList[this.index].children[0].style.color = "";
			footerServiceLiList[this.index].children[0].children[0].src = 
				"../images/service0" + ( this.index + 1 ) + ".png";
		}		
	}
	
	
	
	//footer-links-service中p4对象
	var footerLinksServiceObj = siteFooterObj.children[1].children[1].children[3];
	//footer-links-service中p4对象添加鼠标滑过事件
	footerLinksServiceObj.onmouseover = function(){
		footerLinksServiceObj.style.background = "#ff6700";
		footerLinksServiceObj.children[0].style.color = "#FFF";
		footerLinksServiceObj.children[0].children[0].src = "../images/24hpic1.png";
	}
	//footer-links-service中p4对象添加鼠标离开事件
	footerLinksServiceObj.onmouseout = function(){
		footerLinksServiceObj.style.background = "";
		footerLinksServiceObj.children[0].style.color = "";
		footerLinksServiceObj.children[0].children[0].src = "../images/24hpic01.png";
	}
	
	
}